Skip to content

feat: virtual-scroll rendering for work-item list via --virtualize flag#1425

Merged
SorraTheOrc merged 3 commits into
mainfrom
copilot/implement-virtual-scroll-for-work-item-tree
Apr 8, 2026
Merged

feat: virtual-scroll rendering for work-item list via --virtualize flag#1425
SorraTheOrc merged 3 commits into
mainfrom
copilot/implement-virtual-scroll-for-work-item-tree

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

Blessed materializes every row as a DOM node on setItems(), making large lists (~5k items) unusably slow. This adds an opt-in virtual-scroll path that only passes the visible viewport slice to blessed.

New: VirtualList (src/tui/virtual-list.ts)

Pure indexing class with no blessed dependency — all viewport arithmetic lives here.

const vl = new VirtualList({ totalItems: 5000, viewportHeight: 20 });
vl.selectAbsolute(2500);        // jumps to global index, scrolls viewport
vl.slice(allLines);             // returns the 20-item window to pass to blessed
vl.selectedIndexInViewport;     // viewport-relative index for list.select()

Controller wiring (src/tui/controller.ts)

  • Added getGlobalSelectedIndex() — converts list.selected (viewport-relative when virtual) to the full-list index. Replaces every list.selected as number call site.
  • renderListAndDetail: when vl is set, updates viewport height from the widget, calls vl.slice(lines) instead of passing all lines, and syncs list.select(vl.selectedIndexInViewport).
  • listKeypressHandler: detects when the cursor hits the viewport edge and calls vl.scrollBy(±1) + re-render rather than letting blessed silently ignore the keypress.
  • Mouse-click handler: converts the viewport-relative click row to a global index before calling renderListAndDetail.
  • updateListSelection: applies vl.offset + idx conversion before updating the detail pane.

Layout / CLI

  • CreateLayoutOptions.virtualize?: boolean — when set, createLayout returns a pre-configured VirtualList in layout.virtualList.
  • wl tui --virtualize flag wires this through controller.start().

Tests

27 unit tests in test/tui/virtual-list.test.ts covering moveBy, selectAbsolute, scrollBy, slice, setTotalItems, setViewportHeight, and boundary conditions. Existing TUI tests unaffected.

Copilot AI linked an issue Apr 7, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add full virtualization of work-item tree feat: virtual-scroll rendering for work-item list via --virtualize flag Apr 7, 2026
Copilot AI requested a review from SorraTheOrc April 7, 2026 23:58
@SorraTheOrc SorraTheOrc marked this pull request as ready for review April 8, 2026 13:26
@SorraTheOrc SorraTheOrc merged commit 2be6e11 into main Apr 8, 2026
3 of 4 checks passed
@SorraTheOrc SorraTheOrc deleted the copilot/implement-virtual-scroll-for-work-item-tree branch April 28, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Full virtualization of work‑item tree

2 participants